package com.ebiz.mockup.utils
{
	import com.ebiz.mockup.component.BoardCell;
	import com.ebiz.mockup.component.IBoardJoint;

	public class CheckUtils
	{
		public function CheckUtils()
		{
		}
		
		public static function getJointAmongCells($cell0:BoardCell,$cell1:BoardCell,$cell2:BoardCell):IBoardJoint{
			var $joint:IBoardJoint = getJointBetweenCells($cell0,$cell1);
			if($joint==null){
				return null;
			}
			if($cell2.holdJoints.indexOf($joint)==-1){
				return null;
			}
			return $joint;
		}
		
		public static function getJointBetweenCells($cell0:BoardCell,$cell1:BoardCell):IBoardJoint{
			var i:int;
			var j:int;
			var len0:int = $cell0.holdJoints.length;
			var len1:int = $cell1.holdJoints.length;
			for(i=0;i<len0;i++){
				var $joint0:IBoardJoint = $cell0.holdJoints[i];
				for(j=0;j<len1;j++){
					var $joint1:IBoardJoint = $cell1.holdJoints[j];
					if($joint0==$joint1){
						return $joint0;
					}
				}
			}
			return null;
		}
	}
}